
	import {util} from '@/static/js/common.js';

	//删除订单
	const deleteOeder=(order_id,call)=>{
		uni.showModal({
			content: '是否确定删除？',
			success: function (res) {
				if (res.confirm) {
					util.get_request(
						{
							type:'deleteOeder',
							order_id:order_id,
						},
						(res)=>{
							if(call){
								call(res)
							}
						}
					);
				}
			}
		});
	}
	/**
	 * 拣货完成
	*/
	const onclickSuccess=(goods_id,route_id,callback)=>{
		util.get_request(
			{
				type:'jh_success',
				goods_id:goods_id,
				route_id:route_id
			},
			(res)=>{
				if(callback){
					callback(content)
				}
			}
		);
	}
	/**
	 * 设置、取消为积分商品
	*/
	const sendGoodsScore=(goods_id,goodsScore,callback)=>{
	
		util.get_request(
			{
				type:'sendGoodsScore',
				goods_id:goods_id,
				goodsScore:goodsScore
			},
			(res)=>{
				if(callback){
					callback(res)
				}
			}
		);
	}
	//打印货位标签
	const printPositionLabel=(positionArr)=>{
		uni.showModal({
			title:'请输入需要打印货位标签的数量',
			editable:true,
			content:'1',
			placeholderText:'0',
			success: (e)=>{
				if(e.confirm){
					var count = e.content
					if(count.length<=0){
						return
					}
					count = count.replace(/\s+/g, '')
					if(count <= 0){
						util.showModal('输入的数量小于等于0')
						return
					}
					var arr = [];
					
					if (Array.isArray(positionArr)){
					   for(var i=0;i<positionArr.length;i++){
					   	arr.push({type:2,content:positionArr[i],count:count})
					   }
					} else {
					   	arr.push({type:2,content:positionArr,count:count})
					}
					
					var jsonData = JSON.stringify(arr)
					util.get_request(
						{
							type:'qrcode_print_send',
							json_data:jsonData,
						},
						(res)=>{
							util.toast(res.msg)
						}
					);
				}
			}
		})
	}

	//打印标签
	const printLabel=(goods_id)=>{
		uni.showModal({
			title:'请输入需要打印商品标签的数量',
			editable:true,
			content:'1',
			placeholderText:'0',
			success: (e)=>{
				if(e.confirm){
					var count = e.content
					if(count.length<=0){
						return
					}
					count = count.replace(/\s+/g, '')
					if(count <= 0){
						util.showModal('输入的数量小于等于0')
						return
					}
					var arr = [];
					arr.push({type:1,content:goods_id,count:count})
						
					var jsonData = JSON.stringify(arr)
					
					util.get_request(
						{
							type:'qrcode_print_send',
							json_data:jsonData,
						},
						(res)=>{
							util.toast(res.msg)
						}
					);
					
				}
			}
		})
	}

	/**
	 * 商品信息-昵称修改
	*/
	const updateGoodsName=(goods_id,updateName)=>{
		util.get_request(
			{
				type:'updateGoodsName',
				name:encodeURIComponent(updateName),
				goods_id:goods_id,
			},
			(res)=>{
				util.toast(res.msg)
			}
		);
	}
	export const req= { 
		printLabel,deleteOeder,onclickSuccess,sendGoodsScore,printPositionLabel,
		updateGoodsName,
		
	}